<#assign webroot=request.getContextPath()>
<#import "../../common/main.ftl" as main/>
<#assign menu_index=0 in main>
<#assign menu_index_sub=3 in main>
<@main.layout myTemplate=books/>
<#macro books>
<script>
    function checkFiles()
     {
      var file = document.getElementById("ffile").value;  
       var strRegex = "(.txt|.TXT)$";
       var re=new RegExp(strRegex);
        if(re.test(file.toLowerCase())){
           return true;
         }else{
           alert("文件格式错误，请上传txt文本文件"); 
           return false;
          }
     }
</script>
<h1><span class="lf">数据管理>><a href="${webroot}/data_mgr/book">书籍管理</a>>>新增图书</span>
	<#-- 	<a href="#" class="rt">返回</a> -->
</h1>
<div class="user">
    <div class="admin_top1"> <h3>新增图书</h3> </div>
	<div class="new_area">
	<form action="${webroot}/data_mgr/book/create" enctype="multipart/form-data" method="post">
		  <table >
    <colgroup>
    	<col width="20%" />
    	<col width="70%" />
    </colgroup>
	<tr>
		<th>图书标题:</th>
		<th><input type="text" name="title"  /></th>
	</tr>
		<tr>
		<th>类别类别:</th>
		<th>
		   <select name="category_id">
		        <#list categories as category>
		            <option value ="${category.id}">${category.name}</option>
		        </#list>
		   </select>
		</th>
	</tr>
	<tr>
		<th>消耗积分:</th>
		<th>
		<select name="payment">
		<option value ="0">无需积分</option>
        <option value ="1">1分</option>
        <option value="2">2分</option>
        <option value="3">3分</option>
        <option value="4">4分</option>
         <option value="5">5分</option>
		</select>
		</th>
	</tr>
	<tr>
		<th>文件:</th>
		<th><input type="file"  name="book_file" id="ffile"/></th>
	</tr>
	<tr>
		<td colspan="2" align="left"><input type="submit" class="queding"  onclick="return checkFiles();"/></td>
	</tr>
</table>
</form>
</#macro>